// 表格列配置
export const regularColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '銷售額下限（≥）',
    dataIndex: 'lowerLimit',
    customRender: ({ text }) => {
      return `$ ${Number(text).toLocaleString()}`
    },
  },
  {
    title: '銷售上限（<）',
    dataIndex: 'upperLimit',
    customRender: ({ text }) => {
      return `$ ${Number(text).toLocaleString()}`
    },
  },
  {
    title: '總銷售分成',
    dataIndex: 'totalSalesShare',
    customRender: ({ text }) => {
      return `${text}%`
    },
  },
  {
    title: '處方分成',
    dataIndex: 'prescriptionShare',
    customRender: ({ text }) => {
      return `${text}%`
    },
  },
  {
    title: '蟲草分成',
    dataIndex: 'cordycepsShare',
    customRender: ({ text }) => {
      return `${text}%`
    },
  },
  {
    title: '幹燕分成',
    dataIndex: 'cubiloseShare',
    customRender: ({ text }) => {
      return `${text}%`
    },
  },
]

export const getRegularTableColumns = (ruleType: number) => {
  if (ruleType == 1) {
    return regularColumns.filter((item) => item.dataIndex !== 'totalSalesShare')
  } else if (ruleType == 2) {
    return regularColumns.filter(
      (item) =>
        item.dataIndex !== 'prescriptionShare' &&
        item.dataIndex !== 'cordycepsShare' &&
        item.dataIndex !== 'cubiloseShare'
    )
  }
}

export const extraColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '產品類型',
    dataIndex: 'productCate',
    customRender: (data) => {
      if (data.value === 1) {
        return '安宮系列'
      } else if (data.value === 2) {
        return '本廠'
      } else if (data.value === 3) {
        return 'OEM'
      } else {
        return '未知'
      }
    },
  },
  {
    title: '銷售額下限（>）',
    dataIndex: 'lowerLimit',
  },
  {
    title: '銷售額上限（≤）',
    dataIndex: 'upperLimit',
  },
  {
    title: '分成比例',
    dataIndex: 'shareRatio',
  },
]
